package vip.lsjscl.flowboot.workflow.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import vip.lsjscl.flowboot.workflow.entity.DKWorkflowVersion;

import java.util.List;

/**
 * 工作流版本存储库
 *
 * @author zhangxingju
 * @date 2025/02/14
 */
@Repository
public interface DKWorkflowVersionRepository extends JpaRepository<DKWorkflowVersion, String> {
    @Query("SELECT COALESCE(MAX(v.version), 0) FROM DKWorkflowVersion v WHERE v.workflowId = ?1")
    Integer findMaxVersionByWorkflowId(@Param("workflowId") String workflowId);

    // 添加这个方法，用于获取指定工作流的所有版本
    List<DKWorkflowVersion> findByWorkflowIdOrderByVersionDesc(String workflowId);
} 